<!-- chart4 -->
<template>
  <div class="chart4">
    <div class="chart4-title">{{ this.title }}</div>

    <div v-if="loadingFlag" class="e-loading">
      <dv-loading style="color: #fff">Loading...</dv-loading>
    </div>

    <div v-else id="c4">
      <div class="c4-info">
        <ul>
          <li>
            <div class="li-left">
              <span class="li-title">检验检测</span>
            </div>
            <div class="li-right">
              <div
                class="li-right-box"
                @click="toListPage('postGetNearDeviceList', '及期未检设备数', 0)"
              >
                <span>及期未检提醒</span>
                <span>{{ lookmData.expireDevNum || "0" }}</span>
              </div>
              <div
                class="li-right-box"
                @click="toListPage('postGetOutDeviceList', '超期未检设备数', 0)"
              >
                <span>超期未检提醒</span>
                <span>{{ lookmData.outDevNum || "0" }}</span>
              </div>
            </div>
          </li>
          <li>
            <div class="li-left">
              <span class="li-title">隐患处置</span>
            </div>
            <div class="li-right">
              <div
                class="li-right-box danger-total"
                @click="toListPage('postGetHiddenList', '隐患条数', 0)"
              >
                <span>隐患总数</span>
                <span>{{ lookmData.hiddenNum || "0" }}</span>
              </div>
              <div
                class="li-right-box"
                @click="toListPage('postGetHiddenList', '隐患条数', 1)"
              >
                <span>一般隐患</span>
                <span>{{ lookmData.comHidNum || "0" }}</span>
              </div>
              <div
                class="li-right-box"
                @click="toListPage('postGetHiddenList', '隐患条数', 3)"
              >
                <span>重大隐患</span>
                <span>{{ lookmData.impHidNum || "0" }}</span>
              </div>
            </div>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  //import引入的组件需要注入到对象中才能使用
  components: {},
  data() {
    //这里存放数据
    return {
      title: "预警信息",
      loadingFlag: true,
      lookmData: {},
    };
  },
  //监听属性 类似于data概念
  // computed: {
  //   areaCode() {
  //     return this.$store.state.listAreaIndex;
  //   },
  // },
  // //监控data中的数据变化
  // watch: {
  //   areaCode(newVal, oldVal) {
  //     console.log("区域code有改动 -- chart4: [" + newVal + "]");
  //     this.init();
  //   },
  // },
  //方法集合
  methods: {
    toListPage(dataType, title, index) {
      this.$store.commit("clearIndex");
      this.$store.commit("setListCategory", dataType);
      this.$store.commit("setListTitle", title);
      this.$store.commit("setListTypeIndex", index);
      let params = {};
      this.$router.push({
        name: "list-page",
        params: params,
      });
    },
    init() {
      this.loadingFlag = true;
      let area_code = this.$store.getters.getAreaList[
        this.$store.getters.getListAreaIndex
      ]["area_code"];
      let params = { area_code };
      this.$http.postScreenlookm(params).then((e) => {
        let ret = e.data;
        if (ret.errorCode != 0) {
          console.log("后台运行异常!");
          return console.log(ret);
        }
        // console.log(ret);
        this.lookmData = ret.data;

        this.$nextTick(() => {
          //   this.chart6(ret.data);
          // console.log(this.lookmData);
          this.loadingFlag = false;
        });
      });
    },
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    this.init();
  },
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {}, //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>
<style lang='less' scoped>
//@import url(); 引入公共css类
.chart4 {
  width: 100%;
  height: 100%;
  position: relative;
  .chart4-title {
    // background-color: #141b47;
    color: @FontColor;
    font-size: 0.22rem;
    font-weight: bold;
    height: 15%;
    line-height: 150%;
  }
  #c4 {
    width: 100%;
    height: 85%;
    position: relative;
    .c4-info {
      height: 100%;
      font-size: 0.2rem;
      color: @FontColor;
      ul {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
        li {
          flex: 1;
          display: flex;
          background-color: @WarnBgColor;
          .li-left {
            flex: 1;
            display: flex;
            justify-content: center;
            align-items: center;
            // border-bottom: 1px dashed #ccc;
            border-right: 1px solid #ccc;
            span {
              color: @LeftTitleColor;
            }
          }
          .li-right {
            flex: 2;
            display: flex;
            flex-direction: column;
            .li-right-box {
              width: 100%;
              flex: 1;
              display: flex;
              justify-content: space-evenly;
              align-items: center;
              border-bottom: 1px solid #ccc;
              span {
                text-align: right;
              }
            }
            .li-right-box.danger-total {
              background-color: @WarnTotalBgColor;
            }
          }
        }
        li:nth-child(odd) {
          background-color: @CheckBgColor;
        }
      }
    }
  }
  .e-loading {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
  }
}
</style>